package com.rfsp.mcp.controller.hos;

import com.rfsp.common.shiro.ShiroUtils;
import com.rfsp.common.util.XssUtils;
import com.rfsp.common.pojo.po.UserPO;
import com.rfsp.mcp.pojo.po.OrgYbjPO;
import com.rfsp.mcp.pojo.vo.PfmVO;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;
import com.rfsp.common.base.ResultListVO;
import com.rfsp.mcp.pojo.sdto.BargainSDTO;
import com.rfsp.common.pojo.sdto.PageSDTO;
import com.rfsp.mcp.pojo.vo.BargainVO;
import com.rfsp.mcp.service.BargainService;

@RequiresRoles(value={"mcp_hos"}, logical= Logical.AND)
@Controller("HosBargainController")
@RequestMapping("/hos/bargain")
public class HosBargainController extends HosController {
	
	@Autowired
	BargainService bargainService;

    @RequestMapping("/")
    public String index1(ModelMap model, PageSDTO pageSdto, BargainSDTO sdto) {
        return index(model,pageSdto,sdto);
    }
    @RequestMapping("/index")
    public String index(ModelMap model, PageSDTO pageSdto, BargainSDTO sdto) {

        //获取登录时选择的医保平台vo
        PfmVO pfm = ShiroUtils.getAttribute("mcp_pfm");
        OrgYbjPO ybj = ShiroUtils.getAttribute("org_ybj");

        sdto=XssUtils.replaceXss(sdto);

        sdto.setValidity("1");
        UserPO currentUser = ShiroUtils.getCurrentUser();
        sdto.setMiOrgId(currentUser.getOrgId());
        sdto.setPfmId(pfm.getId());
        sdto.setOrgYbjId(ybj.getId());
        PageInfo<BargainVO> page = bargainService.list(sdto, pageSdto);
        bargainService.combo(page.getList());
        
        ResultListVO<BargainVO> vo = ResultListVO.success(page,sdto);
        model.put("vo", vo);
        
        return "hos/bargain/index";
    }

/*
    @GetMapping("/detail")
    public String detail(ModelMap model,Long id) {
        
        BargainVO vo = bargainService.getById(id);
        
        ResultVO<BargainVO> result = ResultVO.success(vo);
        model.put("vo", result);
        
        return "hos/bargain1/detail";
    }
*/
}